/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

package com.huawei.housekeeper.controller.request;

import com.huawei.housekeeper.common.request.PageRequest;

import com.baomidou.mybatisplus.annotation.TableField;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.validator.constraints.Length;

/**
 * 用户分页查询对象
 *
 * @author l84165417
 * @since 2022/1/26 15:18
 */
@Getter
@Setter
@ApiModel("用户分页查询对象")
public class PageQueryUserDto extends PageRequest {
    @Length(max = 255, message = "最大长度:255")
    @ApiModelProperty(value = "用户名", required = false)
    private String userName;

    @ApiModelProperty(value = "用户角色", required = false)
    @TableField("USER_ROLE")
    private Integer userRole;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        PageQueryUserDto that = (PageQueryUserDto) o;

        return new EqualsBuilder().appendSuper(super.equals(o))
            .append(userName, that.userName)
            .append(userRole, that.userRole)
            .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()).append(userName).append(userRole).toHashCode();
    }
}
